<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //你有一个 `user` 对象数组，每个对象都有 `user.name`。编写将其转换为 names 数组的代码。
        var users = [{
            name: "John",
            age: 25
        }, {
            name: "Pete",
            age: 30
        }, {
            name: "Mary",
            age: 28
        }];
        var names = [];
        for (var i = 0; i < users.length; i++) {
            names.push(users[i]['name'])
        }


        console.log(names); // John, Pete, Mary
    </script>
</body>

</html>